package com.njwb.day15.zqzb.method.ann5;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.Properties;

public class MySourceLoadProcess {


    //解析操作
    public static  Properties loadResource(){
        Properties properties = new Properties();
        try {
            Field field = Config.class.getDeclaredField("path");
            MyReSource annotation = field.getAnnotation(MyReSource.class);
            String resource = annotation.name();
            InputStream inputStream = Config.class.getClassLoader().getResourceAsStream(resource);
            properties.load(inputStream);
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return properties;
    }
}
